﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int m = int.Parse(Console.ReadLine());
            for (int i = 0; i < m; i++)
            {
                string pat = Console.ReadLine();
                Console.WriteLine(pat[4]);
            }
        }
    }
}
